public class Problem4 {

    public static void main(String[] args) {
	int plus = 0;
	String palindrom = new String();
	String strin = new String();
	int counter = 0;
	for (int i = 999; i >= 1; i--) {
	    for (int j = 999; j >= 1; j--) {
		plus = i * j;
		palindrom = String.valueOf(plus);
		StringBuilder first = new StringBuilder(palindrom);
		first.reverse();
		strin = first.toString();
		if (strin.equals(palindrom)) {
		    if (counter < Integer.parseInt(palindrom)) {
			counter = Integer.parseInt(palindrom);
		    }
		}
	    }
	}
	System.out.println(counter);
    }
}
